package com.justgame.project.service.system.controller;


import com.justgame.project.base.annotation.ProtectAccess;
import com.justgame.project.cloud.common.constant.Result;
import com.justgame.project.cloud.common.entity.PageRequest;
import com.justgame.project.service.system.service.SysStationOrderService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/sys/station-order")
public class SysStationOrderController {

    @Resource
    private SysStationOrderService stationOrderService;

    /**
     * 站内货币系统交易 （JCoin支付）
     *
     * @param gameId
     * @return
     */
    @PutMapping("/buy-game")
    @ProtectAccess(value = 3L, message = "您访问的太快了！请稍后再试")
    public Result<Object> buyGame(@RequestParam String gameId) {
        boolean success = stationOrderService.buildOrder(gameId);
        return Result.status(success, success ? "购买成功啦！" : "哎呀，购买失败了！");
    }

    /**
     * 已购项目
     *
     * @param pageRequest 分页
     * @return
     */
    @GetMapping("purchase-list")
    public Result<?> getPurchaseList(PageRequest<Map<String, Object>> pageRequest) {
        return Result.OK(stationOrderService.getPurchaseList(pageRequest));
    }


}
